package gameUtils;

/**
 * 
 * @author Julio Sousa - 34408 - Iscte-iul
 * 
 *	Representation of a Coordinate (Abciss ,Ordinate)
 */
public class Coordinate {

	private int abcissa, ordinate;

	/**
	 * Creates an instance of Coordinate with an abscissa of zero and an ordinate of zero.
	 */
	public Coordinate(){
		super();
		abcissa = 0;
		ordinate = 0;
	}
	/**
	 * Creates an instance of Coordinate whose abscissa and ordinate are 
	 * the same as for the specified values.
	 * @param abcissa  - the specified Coordinate abscissa value
	 * @param ordinate - the specified Coordinate ordinate value
	 */
	public Coordinate(final int x, final int y){
		abcissa = x;
		ordinate = y;
	}
	/**
	 * Return the value of the coordinate abscissa int precision
	 * @return the value of the abscissa Coordinate
	 */
	public int getAbcissa() {
		return abcissa;
	}
	/**
	 *  Sets the abscissa of this Coordinate object to the specified abscissa
	 * @param abcissa - the new abscissa for the Coordinate Object
	 */
	public void setAbcissa(final int abcissa) {
		this.abcissa = abcissa;
	}
	/**
	 * Return the value of the ordinate in int precision
	 * @return the value of the ordinate Coordinate
	 */
	public int getOrdinate() {
		return ordinate;
	}
	/**
	 * Sets the ordinate of this Coordinate object to the specified ordinate
	 * @param ordinate - the new ordinate for the Coordinate object
	 */
	public void setOrdinate(final int ordinate) {
		this.ordinate = ordinate;
	}
	/**
	 * Checks whether two coordinate objects have equal values.
	 */
	@Override
	public boolean equals(final Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Coordinate other = (Coordinate) obj;
		if (this.getAbcissa() != other.getAbcissa())
			return false;
		if(this.getOrdinate() != other.getOrdinate()){
			return false;
		}
		return true;
	}
	/**
	 * Returns a string representation of the values of this 
	 * Coordinate object's abscissa and ordinate fields.
	 */
	@Override
	public String toString(){
		return "Coordinate(" + this.getAbcissa() + "," + this.getOrdinate() + ")";
	}

}
